package com.ti.srpglife.Screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.World;
import com.ti.srpglife.SRPGLIFEGame;
import com.ti.srpglife.entity.Unit;
import com.ti.srpglife.util.Art;


public class GameScreen extends AbstractScreen
{
	
	public GameScreen(SRPGLIFEGame g) 
	{
		super(g);
	}
	
	//TODO: move update-ish functions to a new method, use this one for showing UI
	public void render(float delta) 
	{
		super.render(delta);
		
		//handle inputs
		if(Gdx.input.isButtonPressed(Buttons.LEFT))
		{
			//select at Gdx.input.getX(),Gdx.input.getY()
			SRPGLIFEGame.world.trySelect(Gdx.input.getX(),Gdx.input.getY());
		}
		if(Gdx.input.isButtonPressed(Buttons.RIGHT))
		{
			//pass attack command to level
			SRPGLIFEGame.world.tryAct(Gdx.input.getX(),Gdx.input.getY());
		}
		
		Vector2 cammove = new Vector2(0,0);
		if(Gdx.input.isKeyPressed(Keys.LEFT))
		{
			cammove.add(-10,0);
		}
		if(Gdx.input.isKeyPressed(Keys.RIGHT))
		{
			cammove.add(10,0);
		}
		if(Gdx.input.isKeyPressed(Keys.UP))
		{
			cammove.add(0,10);
		}
		if(Gdx.input.isKeyPressed(Keys.DOWN))
		{
			cammove.add(0,-10);
		}

		SRPGLIFEGame.world.moveCam(cammove);
	}

	public void resize(int width, int height) 
	{
		super.resize(width,height);
	}

	public void show() {}
	public void hide() {}
	public void pause() {}
	public void resume() {}

	public void dispose() {
		super.dispose();
	}
}
